﻿using System;
using System.Data;
using CoreLab.Oracle; //using Devart.Data.Oracle; //using Oracle.DataAccess.Client;
using System.Web;
using System.Web.Caching;


using LMD.Constant;
using LMD.Lib.Oracle;

namespace Cached
{
    /// <summary>
    /// Summary description for PICPositionTable
    /// </summary>
    public class PICPositionTable : CacheAbstraction
    {
        public DataTable GetPICPosition()
        {
            return GetPICPosition(false);
        }
        public DataTable GetPICPosition(bool bForceRefresh)
        {
            String sxCacheKey = KCache.P_PIC_POSITION;

            if(bForceRefresh)
            {
                HttpRuntime.Cache.Remove(sxCacheKey);
            }

            if (HttpRuntime.Cache[sxCacheKey] == null)
            {
                DBLib dbl = new DBLib();

                String sxQuery =
                    @"
                    select
                        P_PIC_POSITION_ID ID,
                        CODE
                    from 
                        sni.P_PIC_POSITION
                    order by
                        CODE ASC
                    ";

                DataTable dt = dbl.GetDataTable(sxQuery);

                AddToCache(sxCacheKey, dt, CacheType.Daily);
                
            }
            return (DataTable)HttpRuntime.Cache[sxCacheKey];
        }        

        public override String GetCacheFilename()
        {
            return KCache.Filename.PARAMETER_TABLE;
        }
    }
}